package com.flyu.mySocket;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;

public class UdpClientDome2 {
    public static void main(String[] args) throws Exception {
        // 创建连接
        DatagramSocket socket = new DatagramSocket();
        // 准备数据，从控制台读取System.in
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            String data = reader.readLine();
            byte[] bytes = data.getBytes();
            DatagramPacket packet = new DatagramPacket(bytes, 0, bytes.length, new InetSocketAddress("127.0.0.1", 6666));
            socket.send(packet);
            if (data.equals("bye")){
                break;
            }
        }


        socket.close();

    }
}
